package com.bskj.sj.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.bskj.common.bean.model.ParkInfo;
import com.bskj.sj.bean.vo.resp.ParkDailyTransferDetailRespVo;
import com.bskj.common.dao.ParkInfoDao;
import com.bskj.common.dao.core.BaseDao;
import com.bskj.sj.service.IParkInfoService;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ParkInfoServiceImpl extends BaseServiceImpl<ParkInfo> implements IParkInfoService {
    @Autowired
    private ParkInfoDao parkInfoDao;

    @Override
    public BaseDao<ParkInfo> getBaseDao() {
        return parkInfoDao;
    }

    @Override
    public List<ParkInfo> getParkInfo(ParkInfo parkInfo) throws Exception {

        return parkInfoDao.getParkInfo(parkInfo);
    }

    public List<Map<String, Integer>> getDailyCharge(ParkInfo parkInfo) throws Exception {

        return parkInfoDao.getDailyCharge(parkInfo);
    }

    @Override
    public List<ParkInfo> getTransferDetail(int custId) throws Exception {
        ParkInfo parkInfo = new ParkInfo();
        parkInfo.setParkLotCustimerId(custId);
        parkInfo.setChargeType(2);
        List<ParkInfo> parkInfos = getParkInfo(parkInfo);
        return parkInfos;
    }

    @Override
    public List<ParkDailyTransferDetailRespVo> getDailyTransfer(int parkLotCustimerId, int chargeType, Integer page, Integer pageSize) throws Exception {
        List<ParkDailyTransferDetailRespVo> voList = new ArrayList<>();
        ParkInfo parkInfo = new ParkInfo();
        parkInfo.setParkLotCustimerId(parkLotCustimerId);
        parkInfo.setChargeType(2);
        List<Map<String, Integer>> mapList = parkInfoDao.getDailyTransfer(parkInfo);
        for ( Map<String, Integer> map : mapList){
            ParkDailyTransferDetailRespVo parkDailyTransferDetailRespVo = new ParkDailyTransferDetailRespVo();
            BeanUtils.populate(parkDailyTransferDetailRespVo, map);
            voList.add(parkDailyTransferDetailRespVo);
        }
        return voList;
    }

}
